<template>
  <div class="love">
    <van-nav-bar
      title="我的收藏"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft()"
    >
      <template #right>
        <van-icon name="search" size="18" />
      </template>
    </van-nav-bar>
    <div v-show="lists">
      <div class="card" v-for="(item, index) in lists" :key="index">
        <img :src="item.picUrl" alt="" />
        <div class="center">
          <h2>{{ item.name }}</h2>
          <div class="nav">
            <van-icon name="star" color="orange" />
            <span class="one">{{ item.wmPoiScore / 10 }}</span>
            <span class="sell">{{ item.monthSalesTip }}</span>
          </div>
          <div class="last">
            <span class="two">{{ item.minPriceTip }}</span>
            <span class="three">{{ item.shippingFeeTip }}</span>
            <div class="four">{{ item.deliveryTimeTip }}</div>
            <div class="five">{{ item.distance }}</div>
          </div>
        </div>
      </div>
      <h1>已全部加载完</h1>
    </div>
    <div class="none" v-show="lists==[]">
      空的
    </div>
  </div>
</template>

<script>
import { shop_favlist } from "../api";

export default {
  data() {
    return {
      lists: [],
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
  },
  mounted() {
    var userId = JSON.parse(localStorage.getItem("userinfo")).id;
    console.log(userId);
    shop_favlist({ userid: userId, shopid: this.$store.state.lovelist }).then(
      (res) => {
        console.log(res.data.list);
        this.lists = res.data.list;
        console.log(this.lists);
      }
    );
  },
};
</script>
<style scoped>
.card {
  width: 100%;
  height: 100px;
  background-color: rgba(182, 160, 160, 0.123);
  display: flex;
  margin-top: 10px;
  border-radius: 10px;
}
img {
  width: 80px;
  height: 80px;
  margin-left: 10px;
  margin-top: 10px;
}
.center {
  flex: 1;
  margin-left: 10px;
}
h2 {
  font-size: 18px;
}
.one {
  color: orange;
  display: inline-block;
}
.sell {
  display: inline-block;
  margin-left: 10px;
  color: gainsboro;
}
.three {
  display: inline-block;
  margin-left: 10px;
}
.four {
  display: inline-block;
  margin-left: 30px;
}
.five {
  display: inline-block;
  margin-left: 10px;
}
h1 {
  text-align: center;
  font-size: 16px;
  color: lightgrey;
}
</style>